package com.fankui.crowd.handler;

import com.fankui.crowd.api.MySQLRemoteService;
import com.fankui.crowd.constant.CrowdConstant;
import com.fankui.crowd.entity.vo.PortalTypeVO;
import com.fankui.crowd.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * ClassName PortalHandler
 * Description TODO
 * Date 2023/8/6 9:34
 *
 * @Author 范奎
 * @Since JDK 11
 */
@Controller
public class PortalHandler {
    @Autowired
    private MySQLRemoteService mySQLRemoteService;

    @RequestMapping("/")
    public String showPortalPage(Model model) {
        ResultEntity<List<PortalTypeVO>> resultEntity = mySQLRemoteService.getPortalTypeProjectDataRemote();
        String result = resultEntity.getResult();
        if (ResultEntity.SUCCESS.equals(result)) {
            List<PortalTypeVO> portalTypeVoList = resultEntity.getData();
            model.addAttribute(CrowdConstant.ATTR_NAME_PORTAL_DATA, portalTypeVoList);
        }
        return "portal";
    }
}
